package com.android.multiplesmart.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import com.android.multiplesmart.R;
import com.android.multiplesmart.databinding.DialogSetUsernameBinding;
import com.schillerchina.baselibrary.base.BaseDialog;
import com.schillerchina.baselibrary.constans.AppConstants;
import com.schillerchina.baselibrary.utils.Pref;
import com.schillerchina.baselibrary.utils.ToastUtil;

/**
 * @author zhangzhiguo
 * @date 2020/5/7 10:01 AM
 * @Description:设置域名Dialog
 */
public class SetUserNameDialog extends BaseDialog {
    private Context context;
    private DialogSetUsernameBinding binding;

    private ISureButtonOnclick sureButtonOnclick;

    public SetUserNameDialog(Context context) {
        super(context);
        this.context = context;
        init();
    }

    private void init() {
        setTitle("输入姓名");

        binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_set_username, null, false);
        setContentView(binding.getRoot());
        setCanceledOnTouchOutside(true);
        showBottomDividerLine(true);

        addButton("确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String userName = binding.editUserName.getText().toString().trim();
                if (userName.length() > 0) {

                    if (sureButtonOnclick != null) {
                        sureButtonOnclick.SureButtonOnClick(userName);
                    }
                    dismiss();
                } else {
                    ToastUtil.showToast("请输入姓名");
                }
            }
        });
    }


    public void setOnSureButtonOnClickListener(ISureButtonOnclick listener) {
        sureButtonOnclick = listener;
    }

    public interface ISureButtonOnclick {
        void SureButtonOnClick(String userName);
    }


}
